package com.yilin.platform.entity.user;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yilin.platform.base_core.commons.base.BaseEntity;
import com.yilin.platform.base_core.commons.entity.AuthStatusData;
import com.yilin.platform.entity.enums.user.OrganType;
import com.yilin.platform.entity.enums.user.RoleType;
import com.yilin.platform.entity.enums.user.UserType;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "user_account")
@TableName("user_account")
public class Account extends BaseEntity {

    //登录类型
    public enum LoginType {
        pass(0, "密码登录"),
        phone(1, "手机号登录"),
        weChat(2, "微信授权登录"),
        face(3, "人脸识别登录"),
        email(4, "邮箱授权登录");
        @EnumValue
        public Integer index;
        public String name;

        LoginType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    //登录终端类型
    public enum TerminalType {
        android(0, "安卓端"),
        ios(1, "IOS端"),
        web(2, "网页端"),
        applets(3, "小程序"),
        grant(4, "API授权");
        @EnumValue
        public Integer index;
        public String name;

        TerminalType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    //用户状态
    public enum UserState {
        enable(0, "启用中"),
        disable(1, "停用中");
        @EnumValue
        public Integer index;
        public String name;

        UserState(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }



    //登录账户
    @Column(name = "username")
    private String username; //用户名
    @Column(name = "monery")
    private Double monery=0d; //用户名
    @Column(name = "password")
    private String password; //密码 不可给到前端
    @Column(name = "secret_key",columnDefinition = "TEXT")
    private String secretKey;//秘钥 不可给到前端
    @Column(name = "user_state", columnDefinition = "INT default 0")
    private UserState userState;//用户状态
    @Column(name = "token")
    private String token;// 登录token
    @Column(name = "device_id")
    private String deviceId;// 登录设备号
    @Column(name = "login_ips")
    private String loginIps;// 登陆IPs
    @Column(name = "login_type")
    private LoginType loginType;//授权登录类型
    @Column(name = "push_id")
    private String pushId;// 推送ID
    @Column(name = "terminal_type")
    private TerminalType terminalType;//登录终端类型
    @Column(name = "device_position")
    private String devicePosition;//设备位置
    @TableLogic
    @Column(name = "is_deleted", columnDefinition = "INT default 0")
    private Integer isDeleted;  //逻辑删除 以后涉及用户的删除都走这种方式
    //用户信息
    @Column(name = "public_key",columnDefinition = "TEXT")
    private String publicKey; // 公钥，可以给到前端
    @Column(name = "phone")
    private String phone; // 手机号
    @Column(name = "email")
    private String email; // 邮箱
    @Column(name = "alipay_id")
    private String alipayId; // 支付宝ID
    @Column(name = "wechat_id")
    private String wechatId; // 微信ID
    @Column(name = "qq_id")
    private String qqId; // QQ_ID
    @Column(name = "face_id")
    private String faceId; // 人脸ID
    @Column(name = "fingerprint_secret_key",columnDefinition = "TEXT")
    private String fingerprintSecretKey;//指纹秘钥 不可给到前端
    @Column(name = "address")
    private String address; //地址
    @Column(name = "name")
    private String name;  //用户姓名
    @Column(name = "avatar")
    private String avatar;  //头像
    //安全操作
    @Column(name = "last_login_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastLoginTime; //最后登录时间
    @Column(name = "safe_password")
    private String safePassword;// 安全密码 不可给到前端
    @Column(name = "safe_disabled")
    private Boolean safeDisabled = false;// 禁用安全操作true
    @Column(name = "disable_reason")
    private String disableReason;// 禁用原因
    @Column(name = "safe_fail_reason")
    private String safeFailReason;// 密码输入错误，APP环境异常等 都会导致安全验证失败
    //用户角色信息
    @Column(name = "role_name")
    private String roleName;//角色名称
    @Column(name = "user_type")
    private UserType userType;  //用户类型
    @Column(name = "role_type")
    private RoleType roleType;  //角色类型
    @Column(name = "organ_type")
    private OrganType organType;  //社会团体类型
    //上级平台信息 直属运营平台
    @Column(name = "superior_plat_id")
    private String superiorPlatId;
    @Column(name = "superior_plat_name")
    private String superiorPlatName;
    //用户组织信息（企业信息/租户信息）
    @Column(name = "organize_id")
    private String organizeId;//组织ID
    @Column(name = "organize_name")
    private String organizeName;//组织名称
    @Column(name = "organize_logo")
    private String organizeLogo;//组织LOGO
    @Column(name = "organize_manager_user_id")
    private String organizeManagerUserId;//组织管理员用户ID
    @Column(name = "organize_manager_user_name")
    private String organizeManagerUserName;//组织管理员用户名称
    //账户累计资源
    @Column(name = "login_count")
    private int loginCount = 0;// 登陆次数
    @Column(name = "login_err_count")
    private int loginErrCount = 0;// 登陆错误次数,不超过6，超过6后启动密码找回或手机登录
    @Column(name = "safe_fail_count")
    private int safeFailCount = 0;// 安全密码验证失败次数,单日不超过3，超过3后停用安全验证，禁用安全操作， 成功归0，次日归0
    @Transient
    @TableField(exist = false)
    private int totalClinchCount = 0;//总成交量 [运单成交]
    //查询字段
    @Transient
    @TableField(exist = false)
    private String verCode; //验证码--注册时使用
    @Transient
    @TableField(exist = false)
    private Organize organize;//组织信息

    @Transient
    @TableField(exist = false)
    private List<Authority> authorityList;//权限信息
    @Transient
    @TableField(exist = false)
    private List<AuthStatusData> authStatusList;//认证结果信息
    @Transient
    @TableField(exist = false)
    private Boolean forCooperate;//与当前登录用户合作关系
    //数据统计


    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Double getMonery() {
        return monery;
    }

    public void setMonery(Double monery) {
        this.monery = monery;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public UserState getUserState() {
        return userState;
    }

    public void setUserState(UserState userState) {
        this.userState = userState;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getLoginIps() {
        return loginIps;
    }

    public void setLoginIps(String loginIps) {
        this.loginIps = loginIps;
    }

    public LoginType getLoginType() {
        return loginType;
    }

    public void setLoginType(LoginType loginType) {
        this.loginType = loginType;
    }

    public String getPushId() {
        return pushId;
    }

    public void setPushId(String pushId) {
        this.pushId = pushId;
    }

    public TerminalType getTerminalType() {
        return terminalType;
    }

    public void setTerminalType(TerminalType terminalType) {
        this.terminalType = terminalType;
    }

    public String getDevicePosition() {
        return devicePosition;
    }

    public void setDevicePosition(String devicePosition) {
        this.devicePosition = devicePosition;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    public String getPublicKey() {
        return publicKey;
    }

    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAlipayId() {
        return alipayId;
    }

    public void setAlipayId(String alipayId) {
        this.alipayId = alipayId;
    }

    public String getWechatId() {
        return wechatId;
    }

    public void setWechatId(String wechatId) {
        this.wechatId = wechatId;
    }

    public String getQqId() {
        return qqId;
    }

    public void setQqId(String qqId) {
        this.qqId = qqId;
    }

    public String getFaceId() {
        return faceId;
    }

    public void setFaceId(String faceId) {
        this.faceId = faceId;
    }

    public String getFingerprintSecretKey() {
        return fingerprintSecretKey;
    }

    public void setFingerprintSecretKey(String fingerprintSecretKey) {
        this.fingerprintSecretKey = fingerprintSecretKey;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public String getSafePassword() {
        return safePassword;
    }

    public void setSafePassword(String safePassword) {
        this.safePassword = safePassword;
    }

    public Boolean getSafeDisabled() {
        return safeDisabled;
    }

    public void setSafeDisabled(Boolean safeDisabled) {
        this.safeDisabled = safeDisabled;
    }

    public String getDisableReason() {
        return disableReason;
    }

    public void setDisableReason(String disableReason) {
        this.disableReason = disableReason;
    }

    public String getSafeFailReason() {
        return safeFailReason;
    }

    public void setSafeFailReason(String safeFailReason) {
        this.safeFailReason = safeFailReason;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public UserType getUserType() {
        return userType;
    }

    public void setUserType(UserType userType) {
        this.userType = userType;
    }

    public RoleType getRoleType() {
        return roleType;
    }

    public void setRoleType(RoleType roleType) {
        this.roleType = roleType;
    }

    public OrganType getOrganType() {
        return organType;
    }

    public void setOrganType(OrganType organType) {
        this.organType = organType;
    }

    public String getSuperiorPlatId() {
        return superiorPlatId;
    }

    public void setSuperiorPlatId(String superiorPlatId) {
        this.superiorPlatId = superiorPlatId;
    }

    public String getSuperiorPlatName() {
        return superiorPlatName;
    }

    public void setSuperiorPlatName(String superiorPlatName) {
        this.superiorPlatName = superiorPlatName;
    }

    public String getOrganizeId() {
        return organizeId;
    }

    public void setOrganizeId(String organizeId) {
        this.organizeId = organizeId;
    }

    public String getOrganizeName() {
        return organizeName;
    }

    public void setOrganizeName(String organizeName) {
        this.organizeName = organizeName;
    }

    public String getOrganizeLogo() {
        return organizeLogo;
    }

    public void setOrganizeLogo(String organizeLogo) {
        this.organizeLogo = organizeLogo;
    }

    public String getOrganizeManagerUserId() {
        return organizeManagerUserId;
    }

    public void setOrganizeManagerUserId(String organizeManagerUserId) {
        this.organizeManagerUserId = organizeManagerUserId;
    }

    public String getOrganizeManagerUserName() {
        return organizeManagerUserName;
    }

    public void setOrganizeManagerUserName(String organizeManagerUserName) {
        this.organizeManagerUserName = organizeManagerUserName;
    }

    public int getLoginCount() {
        return loginCount;
    }

    public void setLoginCount(int loginCount) {
        this.loginCount = loginCount;
    }

    public int getLoginErrCount() {
        return loginErrCount;
    }

    public void setLoginErrCount(int loginErrCount) {
        this.loginErrCount = loginErrCount;
    }

    public int getSafeFailCount() {
        return safeFailCount;
    }

    public void setSafeFailCount(int safeFailCount) {
        this.safeFailCount = safeFailCount;
    }

    public int getTotalClinchCount() {
        return totalClinchCount;
    }

    public void setTotalClinchCount(int totalClinchCount) {
        this.totalClinchCount = totalClinchCount;
    }

    public String getVerCode() {
        return verCode;
    }

    public void setVerCode(String verCode) {
        this.verCode = verCode;
    }

    public Organize getOrganize() {
        return organize;
    }

    public void setOrganize(Organize organize) {
        this.organize = organize;
    }

    public List<Authority> getAuthorityList() {
        return authorityList;
    }

    public void setAuthorityList(List<Authority> authorityList) {
        this.authorityList = authorityList;
    }

    public List<AuthStatusData> getAuthStatusList() {
        return authStatusList;
    }

    public void setAuthStatusList(List<AuthStatusData> authStatusList) {
        this.authStatusList = authStatusList;
    }

    public Boolean getForCooperate() {
        return forCooperate;
    }

    public void setForCooperate(Boolean forCooperate) {
        this.forCooperate = forCooperate;
    }
}
